#python 3.8
import time
import hmac
import hashlib
import base64
import urllib.parse

url = "https://oapi.dingtalk.com/robot/send?access_token=967e7153afc8423c52f3400a4f234e2c0ac2623a526fe72d034f089b7468add5"

timestamp = str(round(time.time() * 1000))
secret = 'SECe795b5c61f48a7da9d0e4c7bfc0f9a5f0040df106d4e4d2f3c6952745447376e'
secret_enc = secret.encode('utf-8')
string_to_sign = '{}\n{}'.format(timestamp, secret)
string_to_sign_enc = string_to_sign.encode('utf-8')
hmac_code = hmac.new(secret_enc, string_to_sign_enc, digestmod=hashlib.sha256).digest()
sign = urllib.parse.quote_plus(base64.b64encode(hmac_code))
print(timestamp)
print(sign)